package com.yixun.qfbao.util;

import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/9/23.
 */
public class RegexUtils {

//    private  static String DOMAIN = "(https?://(w{3}\\.)?)?\\w+\\.\\w+(\\.[a-zA-Z]+)*(:\\d{1,5})?(/\\w*)*(\\??(.+=.*)?(&.+=.*)?)?";
    private  static String DOMAIN = "[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?";



    public static boolean domainRegex(String domain){
//        return  (Pattern.matches(DOMAIN, domain)||Pattern.matches(IP, domain));
        if(domain == null){
            return false;
        }
        //IP匹配
        String[] domins = domain.split("\\.");
        if(domins.length > 1){
            return true;
        }else{
            return  Pattern.matches(DOMAIN, domain);
        }

    }
}
